package com.jsle.financial.util;

import java.util.UUID;

public class Constants {

	/******************* 返回码常量 start ******************/
    /**
     * 调用成功提示
     */
    public static final int FC_RESULT_SUCCESS_CODE = 1;
    public static final String FC_RESULT_SUCCESS_MESSAGE = "调用成功";
    
    /**
     * 服务器解析错误
     */
    public static final int FC_RESULT_SERVICE_RESOLVE_ERROR_CODE = 500;
    public static final String FC_RESULT_SERVICE_RESOLVE_ERROR_MESSAGE = "服务器解析错误";

    /**
     * 服务器连接DB错误
     */
    public static final int FC_RESULT_SERVICE_DB_ERROR_CODE = 501;
    public static final String FC_RESULT_SERVICE_DB_ERROR_MESSAGE = "服务器连接DB错误";
    
    public class Dao{
    	/**
    	 * 向DB插入数据错误
    	 */
    	public static final int FC_RESULT_INSERT_DAO_ERROR_CODE = 10001;
    	public static final String FC_RESULT_INSERT_DAO_ERROR_MESSAGE = "将 %s 插入数据库错误";
    	
    	/**
    	 * 从DB中删除数据错误
    	 */
    	public static final int FC_RESULT_DEL_DAO_ERROR_CODE = 10002;
    	public static final String FC_RESULT_DEL_DAO_ERROR_MESSAGE = "将 %s 从数据库删除错误";
    	
    	/**
    	 * 更新DB中数据错误
    	 */
    	public static final int FC_RESULT_UPDATE_DAO_ERROR_CODE = 10003;
    	public static final String FC_RESULT_UPDATE_DAO_ERROR_MESSAGE = "更新 DB中的 %s 错误";
    	
    	/**
    	 * 获取DB中数据错误
    	 */
    	public static final int FC_RESULT_QUERY_DAO_ERROR_CODE = 10004;
    	public static final String FC_RESULT_QUERY_DAO_ERROR_MESSAGE = "获取 DB中的 %s 错误";
    }
    
    public class Manager{
    	/**
    	 * 插入DB数据时事务错误
    	 */
    	public static final int FC_RESULT_INSERT_TRANSACTIONAL_ERROR_CODE = 20001;
    	public static final String FC_RESULT_INSERT_TRANSACTIONAL_ERROR_MESSAGE = "将 %s 插入数据库时,事务错误";
    	
    	/**
    	 * 从DB中删除时事务错误
    	 */
    	public static final int FC_RESULT_DEL_TRANSACTIONAL_ERROR_CODE = 20002;
    	public static final String FC_RESULT_DEL_TRANSACTIONAL_ERROR_MESSAGE = "将 %s 从数据库删除时,事务错误";
    	
    	/**
    	 * 更新DB中数据时事务错误
    	 */
    	public static final int FC_RESULT_UPDATE_TRANSACTIONAL_ERROR_CODE = 20003;
    	public static final String FC_RESULT_UPDATE_TRANSACTIONAL_ERROR_MESSAGE = "更新 DB中的 %s 时,事务错误";
    }
    
    /**
     * Service层业务异常
     * @author wisdying
     * @date 2012-10-27
     */
    public class Service{
    	/**
         * 向DB插入数据错误
         */
        public static final int FC_RESULT_INSERT_SERVICE_ERROR_CODE = 30001;
        public static final String FC_RESULT_INSERT_SERVICE_ERROR_MESSAGE = "将 %s 插入数据库错误";
        
        /**
         * 从DB中删除数据错误
         */
        public static final int FC_RESULT_DEL_SERVICE_ERROR_CODE = 30002;
        public static final String FC_RESULT_DEL_SERVICE_ERROR_MESSAGE = "将 %s 从数据库删除错误";
        
        /**
         * 更新DB中数据错误
         */
        public static final int FC_RESULT_UPDATE_SERVICE_ERROR_CODE = 30003;
        public static final String FC_RESULT_UPDATE_SERVICE_ERROR_MESSAGE = "更新 DB中的 %s 错误";
        
        /**
         * 获取DB中数据错误
         */
        public static final int FC_RESULT_QUERY_SERVICE_ERROR_CODE = 30004;
        public static final String FC_RESULT_QUERY_SERVICE_ERROR_MESSAGE = "获取 DB中的 %s 错误";
        
    }
    /**
     * 审批流相关状态
     * @author wisdying
     * @date 2012-11-05
     */
    public class Workflow{
    	/**
    	 * 申请完成
    	 */
    	public static final int FC_WORKFLOW_STATUS_APPLIED = 1;
    	/**
    	 * 审批完成
    	 */
    	public static final int FC_WORKFLOW_STATUS_ASSESSORED = 2;
    	/**
    	 * 最终拍板完成
    	 */
    	public static final int FC_WORKFLOW_STATUS_APPROVED = 3;
    	
    	/**
    	 * 资金申请流程
    	 */
    	public static final int FC_WORKFLOW_TYPE_AMOUNT = 1;
    	/**
    	 * 事件审批流程
    	 */
    	public static final int FC_WORKFLOW_TYPE_EVENT = 2;
    	
    	public static final int FC_WORKFLOW_NODE_1 = 1;
    	public static final int FC_WORKFLOW_NODE_2 = 2;
    	public static final int FC_WORKFLOW_NODE_3 = 3;
    	
    }
    
    /**
	 * UUID 生成器
	 * @return
	 */
	public synchronized static final String getUUID () {
        return UUID.randomUUID().toString();
    }
	
	public class GroupKey{
		
		/**管理员组*/
		public static final String GROUPKEY_MANAGERS = "managers";
		/**流程审核组*/
		public static final String GROUPKEY_WORKFLOWAUDITORS = "workflowAuditors";
		/**流程审批组*/
		public static final String GROUPKEY_WORKFLOWAPPROVERS = "workflowApprovers";
		/**普通用户无组*/
		public static final String GROUPKEY_NAN = "NAN";
	}
	
	public class UserType{
		/**管理员*/
		public static final int USER_ROLE_ISADMIN = 1;
		/**普通用户*/
		public static final int USER_ROLE_ISNORMAL = 2;
		
	}
}
